#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
#include<iterator>
#include<ctime>
#include<cstdlib>
using namespace std;
struct IP {
	string Type,address;
	bool type,used;
	
} a[70001],tcp[70001];
bool check(int k){
	int ad[5]={0},adpoint=0;
	string tmp='\0'+a[k].address;
	int len=a[k].address.length();
	int dotl=0,dotr=0;
	
	for(int i=0;i<len;i++){
		if(a[i].address[i]=='.'){
			dotl=dotr;dotr=i;
			
			for(int j=dotl+1;j<dotr;j++){
				ad[++adpoint]=a[i].address[j]-'0'+ad[adpoint]*10;
			}
		}
	}
	for(int i=1;i<=5;i++){
		if(ad[i]>256){
			return 1;
		}	
	}
	
}
int main() {
	freopen("network.in","r",stdin);
	freopen("network.out","w",stdout);
	int n;
	cin>>n;
	for(int i=1; i<=n; i++) {
		cin>>a[i].Type;
		getchar();
		cin>>a[i].address;

		if(a[i].Type=="Server") a[i].type=0;
		if(a[i].Type=="Client") a[i].type=1;
		tcp[i].address=a[i].address;
		tcp[i].used=0;
	}
	for(int i=1;i<=n;i++){
		bool connect=0,error=0,flag;
		if(check(i)) cout<"Err";
		if(a[i].type==0&&flag==1){
			cout<<"OK"<<endl;
			tcp[i].used=1;
		}
		if(tcp[i].used==1){
			cout<<"Fail";
		}
	}
	fclose(stdin);
	fclose(stdout);
	return 0;
	}
